String encode(String nickname, int[] IP) {
    String s = "tetrisstart "+nickname+" 1.13";
    String h = toString(54*IP[0]+41*IP[1]+29*IP[2]+17*IP[3]);
    int dec = random(0, 255);
    String encodedString = toHex(dec); // toHex converts dec to hex with two characters
    for (int i = 0; i < s.length(); i++) {
        dec = ((dec + s[i]) mod 255) xor h[i mod h.length()];
        encodedString = encodedString+toHex(dec);
    }
    return encodedString;
}